package com.lc.luzhengtang.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.activity.ShopDetailActivity;
import com.lc.luzhengtang.bean.CollectBean;
import com.lc.luzhengtang.conn.Conn;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class CollectionListAdapter extends BaseQuickAdapter<CollectBean.DataBeanX.DataBean, BaseViewHolder> {
    public CollectionListAdapter(List<CollectBean.DataBeanX.DataBean> data) {

        super(R.layout.item_collectionnews, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final CollectBean.DataBeanX.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);
        helper.setText(R.id.text_newstitle, item.getTitle());
        helper.setText(R.id.text_newstime, "￥" + item.getSales());
        Glide.with(mContext).load(Conn.HOST2 + item.getPicurl()).crossFade().into((ImageView) helper.getView(R.id.img_load));
/*
        helper.setTag(R.id.text_newstitle,helper.getAdapterPosition());
        helper.setTag(R.id.text_newstime,helper.getAdapterPosition());
        helper.setTag(R.id.img_load,helper.getAdapterPosition());
        helper.setTag(R.id.img_toast,helper.getAdapterPosition());*/
        helper.addOnClickListener(R.id.img_toast);

        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();

                intent.putExtra("goods_id", item.getGoodsId() + "");
                intent.setClass(mContext, ShopDetailActivity.class);

                mContext.startActivity(intent);

            }
        });

    }


}
